package com.chenhao.generator.constant;

/**
 * 数据库驱动 枚举
 *
 * @author:chenHao
 * @version:1.0
 * @since:1.0
 * @createTime:2019-10-02
 */
public enum DriverClassEnum {
    MYSQL5(1, "com.mysql.jdbc.Driver"),
    MYSQL8(2, "com.mysql.cj.jdbc.Driver");


    DriverClassEnum(Integer code, String driverClassName) {
        this.code = code;
        this.driverClassName = driverClassName;
    }

    private Integer code;

    private String driverClassName;

    public Integer getCode() {
        return code;
    }

    public String getDriverClassName() {
        return driverClassName;
    }

    public static String getDriverClassName(Integer code) {
        if (code == null) {
            return null;
        }
        for (DriverClassEnum value : DriverClassEnum.values()) {
            if (value.getCode().equals(code)) {
                return value.getDriverClassName();
            }
        }
        return null;
    }
}
